<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('批改实验成绩')" />
    <th:block th:include="include :: summernote-css"/>
</head>
<body class="gray-bg">
    <div class="container">
        <div style="text-align: center">
            <br><br>
            <h2 th:text="${report.experimentName}"></h2>
            <input th:value="${report.reportExperimentId}" id="reportExperimentId" type="hidden"/>
            <input th:value="${report.reportStuId}" id="reportStuId" type="hidden"/>
            <input th:value="${report.uuid}" id="uuid" type="hidden"/>
            <br>
            <h3>实验提交日期</h3>
            <span th:text="${#dates.format(report.submitDate,'yyyy-HH-dd HH:mm:ss')}"></span>
            <br>
            <br>
            <br>
            <h3>在线实验结果</h3>
            <input th:value="${report.reportText}" type="text" id="u3dMessage" hidden="hidden"/>
            <div class="row" >
                <div class="col-md-3"></div>
                <div class="col-md-6" id="u3dScore" style="border: 1px solid gainsboro;  box-shadow: 0px 0px 4px gainsboro; border-radius:20px ;background-color: white;">
                    <table class="table" id="dataTable">

                    </table>
                </div>
                <div class="col-md-3"></div>
            </div>
            <br>
            <h3 hidden="hidden">实验报告</h3>
        </div>
        <input th:value="${report.experimentReport}" type="text" id="report" hidden="hidden"/>
        <div class="col-md-12" hidden="hidden">
            <div class="summernote">

            </div>
        </div>
        <div>
            <br>
            <h3 style="text-align: center">请输入教师评语</h3>
            <div>
                <div class="summernote1">

                </div>
            </div>
            <br>
            <br>
            <div class="row">
                <div class="col-md-2"></div>
            <div class="col-md-2">
                <span style="font-size: 20px">请输入分數</span>
            </div>
            <div class="col-md-4">
                <input type="number" class="form-control" id="score" required/>
            </div>
            <div class="col-md-4">
                <input type="button" class="btn btn-warning" value="确定" onclick="checkScore()"/>
            </div>
            </div>
        </div>
        </div>
    </div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
</body>
<script>
    $(function(){
        var u3dScore=$("#u3dMessage").val();
        var array=new Array();
        array=u3dScore.split(",");
        for(var i=0;i<array.length;i++){
            $("#dataTable").append("<tr><td>"+array[i]+"</td></tr>");
        }

        $('.summernote').summernote({
            placeholder: '实验报告内容',
            height : 500,
            lang : 'zh-CN',
            followingToolbar: false,
        });
        $(".summernote").summernote('code',$("#report").val());
        $('.summernote').summernote('disable');


    })

    $('.summernote1').summernote({
        placeholder: '請輸入教師評語',
        height: 500,
        lang: 'zh-CN',
        followingToolbar: false,
    });

    /**
     * 批改成绩，填写评价
     */
    var prefix = ctx + '/system/arrange';

    function checkScore() {
        $.ajax({
            url : prefix + '/checkScore2',
            type : 'post',
            data : {
                "reportExperimentId" : $("#reportExperimentId").val(),
                "reportStuId" : $("#reportStuId").val(),
                "uuid" : $("#uuid").val(),
                "experimentEvaluate" : $(".summernote1").summernote("code"),
                "score" : $("#score").val()
            },
            success : function (data) {
                if(data.code==0){
                    $.modal.msgReload("批改成功",'success')
                }
                if(data.code==500){
                    $.modal.msgReload("批改失败",'error')
                }
            }
        })
    }
</script>
</html>